package org.gitman.agentplatform.ui.actions;

import java.awt.event.ActionEvent;
import java.io.File;

import javax.swing.JFileChooser;

import org.gitman.agentplatform.ui.api.View;
import org.gitman.agentplatform.ui.api.View.MessageType;

public class Export2gnuplot extends UIAction{
		
	public Export2gnuplot() {
		super("Export 3D Gnuplot data");
	}
	
	
	@Override	
	public void actionPerformed(ActionEvent e) {
		JFileChooser fc = new JFileChooser(System.getProperty("installDir") + "/results");
		int rc = fc.showSaveDialog(mainFrame);
		if(rc == JFileChooser.APPROVE_OPTION){
			File f = fc.getSelectedFile();
			try{
				platformManager.getSimulation().saveMultirunStatistics(f);
			}catch (Exception ex) {
				View.showMessage(ex.getMessage(), MessageType.ERROR);
				ex.printStackTrace();
			}			
		}			
	}

}
